<script>
$(function () {
    $("#item_active").click(function () {
        if ($("#item_active").is(':checked')) {
        } else {
            if (<?php echo $result->inventory_current_stock; ?> != 0){
            	alert('There are '+<?php echo $result->inventory_current_stock; ?>+' items left. This action will denied all incoming requests by outlets');
            }
        }
    });
});
</script>

<div class="updatePanel">
	<?php echo form_open('item/updateItem'); ?>
	<div class="titleStyle1">Update Item</div>
	<input name="item_id" type="hidden" value="<?php echo $result->item_id; ?>" />
	<table>
		<tr>
			<td style="color:red; font-size=15px;" colspan="2"><?php echo validation_errors(); ?>
			</td>
		</tr>
		<tr>
			<td>barcode:</td>
			<td><input type="text" name="item_barcode" class="textboxStyle6"
				value="<?php echo $result->item_barcode; ?>" /></td>
		</tr>
		<tr>
			<td>name:</td>
			<td><input type="text" name="item_name" class="textboxStyle6"
				value="<?php echo $result->item_name; ?>" /></td>
		</tr>
		<tr>
			<td>manufacturer:</td>
			<td><input name="manufacturer_name" type="text" class="textboxStyle6"
				value="<?php echo $result->manufacturer_name; ?>" /></td>
		</tr>
		<tr>
			<td>category:</td>
			<td><input name="category_name" type="text" class="textboxStyle6"
				value="<?php echo $result->category_name; ?>" /></td>
		</tr>
		<tr>
			<td>item type:</td>
			<td><select class="textboxStyle4" name="item_type" id="item_type">
					<?php 
					foreach($item_type as $type){
					echo '<option value="'.$type->item_type_id.'">'.$type->item_type_name.'</option>';
				}
				?>
			</select></td>
		</tr>
		<tr>
			<td>cost:</td>
			<td><input name="cost" type="text" class="textboxStyle4"
				value="<?php echo $result->item_cost; ?>" /></td>
		</tr>
		<tr>
			<td>price:</td>
			<td><input name="price" type="text" class="textboxStyle4"
				value="<?php echo $result->item_price; ?>" /></td>
		</tr>
		<tr>
			<td>current stock:</td>
			<td><input name="curr_stock" type="number" class="textboxStyle4"
				value="<?php echo $result->inventory_current_stock; ?>" /></td>
		</tr>
		<tr>
			<td>mininum stock:</td>
			<td><input name="min_stock" type="number" class="textboxStyle4"
				value="<?php echo $result->inventory_min_stock; ?>" />
			</td>
		</tr>
		<tr>
			<td>promotion unit:</td>
			<td><input name="promotion_unit" type="number" class="textboxStyle4"
				value="<?php echo $result->promotion_unit; ?>" /></td>
		</tr>
		<tr>
			<td>discount (percentage):</td>
			<td><input name="promotion_discount" type="number"
				class="textboxStyle4"
				value="<?php echo $result->promotion_discount; ?>" /></td>
		</tr>
		<tr>
			<td>promotion activated:</td>
			<td><input name="promotion_active" type="checkbox"
			<?php if($result->promotion_active) echo 'checked'; ?> /></td>
		</tr>
		<tr>
			<td>available:</td>
			<td><input name="item_active" type="checkbox" id="item_active"
			<?php if($result->item_active) echo 'checked'; ?> /></td>
		</tr>
	</table>
	<div style="margin: 10px">
		<input class="buttonStyle1" value="update" type="submit" />
	</div>
	<?php echo form_close(); ?>

</div>
